/*
 * @Description:
 * @version:
 * @Author: 尹鹏孝
 * @Date: 2025-03-17 22:14:10
 * @LastEditors: 尹鹏孝
 * @LastEditTime: 2025-03-17 22:31:16
 */
import { TypeOrmModuleOptions } from '@nestjs/typeorm';
// import { ConfigModule } from '@nestjs/config';
//  {
//     // type: 'mysql',
//       type:databaseConfig.type,
//       host: 'localhost', // 服务器地址
//         // host: '49.233.15.81', // 服务器地址
//       port: 3306, // 端口号
//       username: 'admin', // 数据库用户名
//       password: '123456', // 数据库密码
//       database: 'sbring', // 数据库名


//       entities: [User,UserDetail,BaseArea,Departments], // 实体类,新增实体类需要注入到entities里面
//       synchronize: true, // 自动同步数据库结构
//     }
// console.log('1-2:', process.env)
import * as dotenv from 'dotenv';

const env = dotenv.config({
    path:'./.development.env'
})
const DATA_BASE = env.parsed
// console.log(env.parsed)
export const databaseConfig: TypeOrmModuleOptions = {
  type: 'mysql',
  host: DATA_BASE.DB_HOST || 'localhost',
  port: parseInt(DATA_BASE.DB_PORT) || 3306,
  // username: DATA_BASE.DB_USERNAME || 'admin',
  // password: DATA_BASE.DB_PASSWORD || '123456',
  // database: DATA_BASE.DB_NAME || 'nestjs',

  username: DATA_BASE.DB_USERNAME || 'root',
  password: DATA_BASE.DB_PASSWORD || '123456',
  database: DATA_BASE.DB_NAME || 'nestjs',


  entities: ['dist/**/*.entity{.ts,.js}'],
  //synchronize: process.env.NODE_ENV !== 'production',
  logging: DATA_BASE.NODE_ENV !== 'production',
  //ssl: process.env.DB_SSL === 'true',
};
